package com.itboye.textileexpres.collection;

import java.util.List;

import com.itboye.textileexpes.beans.CollectionBeans;
import com.itboye.textileexpes.beans.CollectionCateTypeModel;
import com.itboye.textileexpes.beans.ForresterBeans;
import com.itboye.textileexpes.beans.ColletionFenyeBeans.InfoBeans;
import com.itboye.textileexpres.R;
import com.itboye.textileexpres.collection.CollectionGoodsListViewAdapter.ViewHolder;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

public class CollectionGridAdapter extends BaseAdapter {
	Context context;
	List<CollectionCateTypeModel> list;
	int count;
	String name;

	public CollectionGridAdapter(Context context,
			List<CollectionCateTypeModel> list) {
		// TODO Auto-generated constructor stub
		this.context = context;
		this.list = list;
		// this.count = count;
	}

	public CollectionGridAdapter(Context context,
			List<CollectionCateTypeModel> list, int count) {
		// TODO Auto-generated constructor stub
		this.context = context;
		this.list = list;
		this.count = count;
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list == null ? 0 : list.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return list.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder holder = null;
		if (convertView == null) {
			holder = new ViewHolder();
			LayoutInflater inflater = LayoutInflater.from(context);
			convertView = (LinearLayout) inflater.inflate(
					R.layout.item_type_grid, null);
			holder.type_tv = (TextView) convertView.findViewById(R.id.type_tv);
			convertView.setTag(holder);
		} else {
			holder = (ViewHolder) convertView.getTag();
		}
		if (list.size() > 0) {
			holder.type_tv.setText(list.get(position).getName());
		}

		// try {
		// // name = list.get(position).getName();
		// holder.type_tv.setText("1222");
		// } catch (Exception e) {
		// // TODO: handle exception
		// System.out.println("OOOOOOOOOOOO" + name);
		// }

		return convertView;
	}

	class ViewHolder {
		TextView type_tv;

	}

}
